//
//  HRZHomeRecommentItemCell.m
//  EMarket
//
//  Created by 石头 on 2018/9/6.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZHomeRecommentItemCell.h"
// Controllers

// Models
#import "HRZHomeRecommentBaseItem.h"
// Views

// Vendors

// Categories
#import <UIImageView+WebCache.h>
// Others


@interface HRZHomeRecommentItemCell ()
@property (strong, nonatomic) UILabel *mTitle;
@property (strong, nonatomic) UIImageView *mImageV;

@end

@implementation HRZHomeRecommentItemCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.mTitle];
        [self addSubview:self.mImageV];
    }
    return self;
}

- (void)layoutSubviews {
    [self.mTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).mas_offset(5);
    }];
    
    [self.mImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.mTitle.mas_bottom).mas_offset(5);
        make.width.mas_equalTo(self).multipliedBy(0.8);
        make.height.mas_equalTo(self.width).multipliedBy(0.8);
    }];
}

#pragma mark - ----  Getter/Setter  ----
- (void)setModel:(HRZHomeRecommentBaseItem *)model {
    _model = model;
    _mTitle.text = _model.itemName.length ? _model.itemName : @"title";
    [_mImageV sd_setImageWithURL:URLString(_model.itemImageUrl) placeholderImage:PLACEHOLDERIMAGE];
}

- (UILabel *)mTitle{
    if (!_mTitle) {
        _mTitle = [[UILabel alloc] init];
        _mTitle.font = PFR12Font;
    }
    return _mTitle;
}

- (UIImageView *)mImageV{
    if (!_mImageV) {
        _mImageV = [[UIImageView alloc] init];
        _mImageV.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _mImageV;
}

@end
